/**
 * 
 */
package com.bolbachchan.common.ui;

import java.io.Serializable;

/**
 * @author Chaitanya
 * 
 */
public class ScreenMessage implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = -1510989881806885096L;

    private String message;
    private ScreenMessageType messageType;

    /**
     * @author Chaitanya
     * 
     */
    public enum ScreenMessageType {
	/**
	 * 
	 */
	SUCCESS,

	/**
	 * 
	 */
	WARNING,

	/**
	 * 
	 */
	ERROR;

	public String toString() {
	    return this.toString();
	}

	public String getName() {
	    return this.name().toLowerCase();
	}
    }

    /**
     * 
     */
    public ScreenMessage() {

    }

    /**
     * @param messageType
     * @param message
     */
    public ScreenMessage(ScreenMessageType messageType, String message) {
	this.messageType = messageType;
	this.message = message;
    }

    /**
     * @return the message
     */
    public String getMessage() {
	return message;
    }

    /**
     * @param message
     *            the message to set
     */
    public void setMessage(String message) {
	this.message = message;
    }

    /**
     * @return the messageType
     */
    public ScreenMessageType getMessageType() {
	return messageType;
    }

    /**
     * @param messageType
     *            the messageType to set
     */
    public void setMessageType(ScreenMessageType messageType) {
	this.messageType = messageType;
    }

    /*
     * (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
	StringBuilder builder = new StringBuilder();
	builder.append("ScreenMessage [message=");
	builder.append(message);
	builder.append(", messageType=");
	builder.append(messageType);
	builder.append("]");
	return builder.toString();
    }

    /*
     * (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
	final int prime = 31;
	int result = 1;
	result = prime * result + ((message == null) ? 0 : message.hashCode());
	result = prime * result + ((messageType == null) ? 0 : messageType.hashCode());
	return result;
    }

    /*
     * (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
	if (this == obj)
	    return true;
	if (obj == null)
	    return false;
	if (getClass() != obj.getClass())
	    return false;
	ScreenMessage other = (ScreenMessage) obj;
	if (message == null) {
	    if (other.message != null)
		return false;
	}
	else if (!message.equals(other.message))
	    return false;
	if (messageType != other.messageType)
	    return false;
	return true;
    }
}
